<template>
  <van-nav-bar v-if="router.currentRoute.value.path !== '/login'" left-arrow @click-left="onClickLeft"
               @click-right="onClickRight" :title="title">
    <template v-if="router.currentRoute.value.path === '/team' || router.currentRoute.value.path === '/my-team'" #right>
      <van-icon name="add-o" size="18" />
    </template>
  </van-nav-bar>
  <div style="padding-bottom: 60px">
    <router-view />
  </div>
  <van-tabbar v-if="router.currentRoute.value.path !== '/login'" route>
    <van-tabbar-item icon="smile-comment-o" name="index" to="/">找搭子</van-tabbar-item>
    <van-tabbar-item icon="friends-o" name="team" to="/team">组队</van-tabbar-item>
    <van-tabbar-item icon="user-circle-o" name="center" to="/center">我</van-tabbar-item>
  </van-tabbar>
</template>

<script setup lang="ts">
import {useRouter} from "vue-router";
import {ref} from "vue";
import routes from "../config/route";

const router = useRouter();
const onClickLeft = () => history.back();
const onClickRight = () => {
  router.push('/save-team');
};
const title = ref('找搭子');
router.beforeEach((to) => {
  const toPath = to.path;
  const route = routes.find((route) => {
    return toPath == route.path;
  });
  title.value = route.title;
});
</script>
